package com.example.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.example.domain.CourseType;

@Repository
public interface CourseTypeDao extends JpaRepository<CourseType, Integer> {

    @Transactional
    @Modifying
    int deleteByCourseTypeId(Integer courseTypeId);

    List<CourseType> findByPid(Integer pid);

    List<CourseType> findByCourseTypeId(Integer courseTypeId);

    @Transactional
    @Modifying
    int deleteByCourseTypeIdIn(List<Integer> listId);

    @Query(nativeQuery = true, value = "SELECT * FROM course_type WHERE typeName like CONCAT('%',:typeName,'%')")
    List<CourseType> findByTypeNameLike(@Param("typeName") String typeName);

}
